#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstring>
#include<iomanip>
#define endl "\n"
using namespace std;
int sh[25],rr=0;
bool pan[25];
//123,124,125,134,135,145,234,235,245,345
int n,r;
void dfs(int x,int y)
{

	if(x==r+1)
	{
		for(int i=0;i<r;i++)
		{
			cout<<setw(3)<<sh[i];
		}
		cout<<endl;
	}	
	for(int i=y;i<=n;i++)
	{
		if(pan[i]==0)
		{
			sh[x-1]=i;
			pan[i]=1;
			dfs(x+1,i);
			pan[i]=0;
		}
	}
}
int main()
{
	cin>>n>>r;
	dfs(1,1);
}